package com.gexiao;

import com.gexiao.bean.Person;
import com.gexiao.config.MainConfig;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class MainTest {
    public static void main(String[] args) {
        // 传统spring的方式
        // 从资源文件中获取spring上下文
//        ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");
//        Person person = context.getBean(Person.class);
//        System.out.println("person = " + person);

        //注解驱动的方式
        ApplicationContext context = new AnnotationConfigApplicationContext(MainConfig.class);
        Person person = context.getBean(Person.class);
        System.out.println("person = " + person);

        String[] names = context.getBeanNamesForType(Person.class);
        for (String name : names) {
            System.out.println("name = " + name);
        }
    }
}
